function controller()
{
   
	player.move(); 
    
	aiplayer.rand_move();
    aiplayer0.rand_move();


	for(var i =0 ; i<total_npc; i++)
	{	
		eval("findlevel(player, aiplayer"+i+");");

		if( eval("aiplayer"+i+".level") == 1 && eval("aiplayer"+i+".prev_level") !=1)
	 		level_1.push( eval("aiplayer"+i) );
	 	else if (  eval("aiplayer"+i+".prev_level") ==1 && eval("aiplayer"+i+".level") != 1 )
	 		level_1.splice( level_1.indexOf(eval("aiplayer"+i)),1); 

		if( eval("aiplayer"+i+".level") == 2 && eval("aiplayer"+i+".prev_level") !=2)
	 		level_2.push( eval("aiplayer"+i) );
	}



	//console.log(level_1);
}